<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="4" :lg="4" :md="4" :sm="24">
            <a-form-item label="会员昵称">
              <a-input placeholder="请输入会员昵称" v-model="queryParam.nickName"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="4" :lg="4" :md="4" :sm="24">
            <a-form-item label="手机号">
              <a-input placeholder="请输入手机号" v-model="queryParam.userPhone"></a-input>
            </a-form-item>
          </a-col>
            <a-col :xl="4" :lg="4" :md="4" :sm="24">
              <a-form-item label="性别">
                 <a-select v-model="queryParam.sex" placeholder="请选择性别">
                  <a-select-option value="">请选择</a-select-option>
                  <a-select-option value="1">男</a-select-option>
                  <a-select-option value="2">女</a-select-option>
                </a-select>
              </a-form-item>
            </a-col>
              <a-col :xl="4" :lg="4" :md="4" :sm="24">
              <a-form-item label="类别">
                 <a-select v-model="queryParam.userType" placeholder="请选择会员类别">
                  <a-select-option value="">请选择</a-select-option>
                  <a-select-option value="1">普通会员</a-select-option>
                  <a-select-option value="2">商家会员</a-select-option>
                </a-select>
              </a-form-item>
            </a-col>
          <a-col :xl="4" :lg="4" :md="4" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button type="primary" icon="download" @click="handleExportXls('会员管理')">导出</a-button>
    </div>

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table
        ref="table"
        size="middle"
        :scroll="{x:true}"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        class="j-table-force-nowrap"
        @change="handleTableChange">

        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="getImgView(text)" height="25px" alt="" style="max-width:80px;font-size: 12px;font-style: italic;"/>
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="downloadFile(text)">
            下载
          </a-button>
        </template>

        <!-- <span slot="action" slot-scope="text, record"> -->
          <!-- <a @click="handleEdit(record)">编辑</a> -->

          <!-- <a-divider type="vertical" /> -->
          <!-- <a-dropdown>
            <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
            <a-menu slot="overlay">
              <a-menu-item>
                <a @click="handleDetail(record)">详情</a>
              </a-menu-item>
              <a-menu-item>
                <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                  <a>删除</a>
                </a-popconfirm>
              </a-menu-item>
            </a-menu>
          </a-dropdown> -->
        <!-- </span> -->

      </a-table>
    </div>

    <adh-user-modal ref="modalForm" @ok="modalFormOk"></adh-user-modal>
  </a-card>
</template>

<script>

  import '@/assets/less/TableExpand.less'
  import { mixinDevice } from '@/utils/mixin'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import AdhUserModal from './modules/AdhUserModal'

  export default {
    name: 'AdhUserList',
    mixins:[JeecgListMixin, mixinDevice],
    components: {
      AdhUserModal
    },
    data () {
      return {
        description: '会员管理管理页面',
        // 表头
        columns: [
          {
            title: '#',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },
           {
            title:'会员类型',
            align:"center",
            dataIndex: 'userType',
             customRender:(text)=>{
              if(text=='1'){
                 return "普通会员"
               }else if(text=='2'){
                return "商家会员"
               }else{
                 return "未知";
               }
             }
          },
           {
            title:'微信头像',
            align:"center",
            dataIndex: 'userAvtor',
             scopedSlots: { customRender: 'imgSlot' }
          },
          {
            title:'会员昵称',
            align:"center",
            dataIndex: 'nickName'
          },
          {
            title:'手机号',
            align:"center",
            dataIndex: 'userPhone',
             customRender:(text)=>{
               if(!text){
                 return "暂未绑定"
               }else{
                return text
               }
             }
          },
          {
            title:'性别',
            align:"center",
            dataIndex: 'sex',
             ellipsis:true,
             customRender:(text)=>{
               if(text=='0'){
                 return "男"
               }else{
                return "女"
               }
             }
          },
          {
            title:'邮箱地址',
            align:"center",
             ellipsis:true,
            dataIndex: 'email',
            customRender:(text)=>{
               if(!text){
                 return "暂未设置"
               }else{
                return text
               }
             }
          },
         
         
          {
            title:'用户标识',
            align:"center",
            dataIndex: 'openId'
          },
          // {
          //   title: '操作',
          //   dataIndex: 'action',
          //   align:"center",
          //   fixed:"right",
          //   width:147,
          //   scopedSlots: { customRender: 'action' }
          // }
        ],
        url: {
          list: "/adhuser/adhUser/list",
          delete: "/adhuser/adhUser/delete",
          deleteBatch: "/adhuser/adhUser/deleteBatch",
          exportXlsUrl: "/adhuser/adhUser/exportXls",
          importExcelUrl: "adhuser/adhUser/importExcel",
          
        },
        dictOptions:{},
        superFieldList:[],
      }
    },
    created() {
    this.getSuperFieldList();
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      },
    },
    methods: {
      initDictConfig(){
      },
      getSuperFieldList(){
        let fieldList=[];
        fieldList.push({type:'string',value:'nickName',text:'会员昵称',dictCode:''})
        fieldList.push({type:'string',value:'userPhone',text:'手机号',dictCode:''})
        fieldList.push({type:'string',value:'sex',text:'性别',dictCode:''})
        fieldList.push({type:'string',value:'email',text:'邮箱地址',dictCode:''})
        fieldList.push({type:'string',value:'userType',text:'会员类型',dictCode:''})
        fieldList.push({type:'string',value:'userAvtor',text:'微信头像',dictCode:''})
        fieldList.push({type:'string',value:'openId',text:'小程序OPENID',dictCode:''})
        this.superFieldList = fieldList
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>